package com.mazha.rabbitmq.listener;

import com.alibaba.fastjson.JSONObject;
import com.mazha.rabbitmq.pojo.domain.Book;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 使用@RabbitListener注解方法上监听消息
 *
 * @author leizi
 * @create 2023-12-03 22:34
 */
@Component
@Slf4j
public class TestMqReceiver2 {

    /**
     * 监听指定的消息队列（数组类型，可以指定监听多个）
     *
     * @param book
     */
    @RabbitListener(queues = {"chat.room.queue"})
    public void receive(Book book) {
        log.info("使用@RabbitListener注解方法上监听消息:{}", JSONObject.toJSONString(book));
    }

}
